import { Entity, Property } from "@mikro-orm/core";
import { BaseEntity } from "./Base";

@Entity()
export class User extends BaseEntity {
    @Property({ type: "string" })
    name!: string;

    @Property({ type: "string" })
    email?: string;

    //   @Property({ hidden: true })
    @Property({ hidden: true, type: "string" }) // when serializing, will hide the property; but it is available for normal operations
    pass!: string;

    @Property({ nullable: true, hidden: true, type: "string" })
    passResetToken?: string;

    @Property({ type: "numeric", default: 2, columnType: "int" })
    role: number = 2;

    @Property({ type: "numeric", default: 0, columnType: "int" })
    disabled: number = 0;

    @Property({ nullable: true, type: "string" })
    avatar?: string;

    @Property({ nullable: true, type: "string", columnType: "mediumtext" })
    avatarData?: string;

    constructor(name: string, email: string, pass: string) {
        super();
        this.email = email;
        this.name = name;
        this.pass = pass;
    }
}
